﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Web;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;
using WmsService.Security;

namespace WmsService.AOP
{
    public class ValidateTokenCallHandler : ICallHandler
    {
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            var   authen = AuthenticationFactory.GetAuthentication();
            authen.ValidateToken();

            var methodReturn = getNext()(input, getNext);
            return methodReturn;
        }
        public int Order { get; set; }
    }

    public class ValidateTokenCallHandlerAttribute : HandlerAttribute
    {
        public override ICallHandler CreateHandler(IUnityContainer container)
        {
            return new ValidateTokenCallHandler { Order = this.Order };
        }
    }
}